package com.lch.webdemo.util;

import java.util.Random;
import java.util.UUID;

/**
 * Created by owen on 16/8/30.
 */
public class UUIDUtil {
    public static String getUUID(){
        return UUID.randomUUID().toString().replace("-", "");
    }

    public static String getUuid(int length){
        String result = getUUID();
        while (result.length() < length){
            result = result + getUUID();
        }
        int start =  new Random().nextInt(result.length() - length);
        return result.substring(start, start + length);
    }
}
